<?php
namespace  Teachers\Controller;
use Think\Controller;
/**
 * 校园景色
 * 
 * */
class SchoolViewController extends CommonController
{
	/**
	 * 根据School_id获得学校 校园景色
	 * */
	public function index()
	{
                $school_id=$this->showschoolID();
		$img_type=I('get.img_type',1);	//必须指定类型 1
		if($school_id && $img_type){
			$img=M('SchoolImg');
			$map['school_id']=$school_id;
			$map['img_type']=$img_type;
			$img_data=$img->where($map)->select();
		}
	}
	
	/**
	 * 编辑图片
	 * 
	 * */
	public function updateImg(){
		$school_id=$this->showschoolID();
		$img_type=I('post.img_type',1);	//必须指定类型 1
		$img_id=I('post.img _id',1);
		if($img_id && $school_id){
			$img=M('SchoolImg');
			$map['img_id']=$img_id;
			$map['school_id']=$school_id;
			$data=array(
				'img_url'			=>	I('post.img_url','dadasdas.jpg'),
				'img_type'			=>	I('post.img_type',1),
				'img_small_url'		=>	I('post.img_small_url','d2131231s.jpg'),
				'update_user'		=>	I('post.update_user','2134214'),
				'img_description'	=>	I('post.img_description','11111')
			);
			$flag=$img->where($map)->save($data);
			dump($flag);
		}
	
	}
	
	
	/**
	 * 增加高校图片
	 *	 
	 * */
	public function addImg(){
		$school_id=$this->showschoolID();
		$img_type=I('post.img_type',1);	//必须指定类型 1
		if($school_id && $img_type){
			$data=array(
				'school_id'		=>	$school_id,
				'img_url'		=>	I('post.img_url','dadasdas.jpg'),
				'img_type'		=>	I('post.img_type',1),
				'img_small_url'	=>	I('post.img_small_url','d2131231s.jpg'),
				'update_user'	=>	I('post.update_user','2134214'),
				'img_description'	=>	I('post.img_description','11111')
			);
			$img=M('school_img');
				$img_id=$img->add($data);
				if(!$img_id){
					$this->error('新增失败！');
				}
			
		}
	}
		
		
			
		/**
		 * 删除高校图片
		 * 
		 * */
		public function deleteImg(){
			$img_id=I('post.img_id',43);
			$school_id=$this->showschoolID();	//必须指定类型 1
			if($img_id && $school_id){
				$map['img_id']=$img_id;
				dump($map);
				$img=M('SchoolImg');
				$flag=$img->where($map)->delete();
				if(!$flag){
					$this->error('删除失败！');
				}
			}
			
			
		}
	
	
}










